<?php
/**
 * Gerador de salt para senhas
 * Author: Bruno Ramos <contato [AT] brunoramos [DOT] eti [DOT] br>
 * File: secureHash.php
 * Version: 1.0
 */

class secureHash {
	/*
	* Cria Salt
	*/
	public function createSalt() { 
		return $this->salt=uniqid(rand(), true);
	}
	
	/*
	* Cria Hash
	*/
	private function createHash($input,$salt) {
		return $this->hash=hash("sha256",$input.$salt);  //php v5.1.2 ou >
    }
	
    /*
	* Retorna Hash
	*/
	public function returnHash($input) {
		if(strlen($input)<3)
			return false;
		return( array($this->CreateSalt(),$this->CreateHash($input,$this->salt)));
	}

	/*
	* Verifica Hash
	*/
	public function verifyHash($input,$hash,$salt) {
    	$checkHash=$this->CreateHash($input,$salt);
		if($checkHash==$hash)
			return true;
     	else
     		return false; 
	}
}
?>
